package com.leather.user.vo;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.leather.common.result.CodeMsg;
import com.leather.common.result.Result;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;

@Data
public class UserVo implements Serializable {


    private Integer id;

    /**
     * 学生的学号
     * isNullAble:0
     */
    private String number;

    /**
     * 账户密码
     * isNullAble:0
     */
    @JsonIgnore
    private String password;


    private String description;


    private String nickName;


    private String imgUrl;

    public Result validateAdd() {
        if(StringUtils.isBlank(number)) {
            return Result.error(CodeMsg.EMPTY_USER_NUMBER);
        }
        if(StringUtils.isBlank(password)) {
            return Result.error(CodeMsg.EMPTY_USER_PASSWORD);
        }
        if(number.length()!=12) {
            return Result.error(CodeMsg.ERROR_NUMBER_LENGTH);
        }
        return Result.success(0);
    }

}
